<template>
	<view>
		<van-dialog
		  use-slot
		  async-close
		  :show="dialogShow"
		  show-cancel-button
		  confirm-button-open-type="getUserInfo"
		  @close="onClose"
		  @getuserinfo="getUserInfo"
		>
		<view class="dialog">
			<view class="dialog-title van-hairline--bottom">
				{{dialogType ? '转出LAB' : '转入LABtk'}}
			</view>
			<view class="dialog-sum">
				当前账户余额：<text class="sum color2">100LAB</text>
			</view>
		</view>
		<van-field
		  :value="sum"
		  :label="text[dialogType] + '数量'"
		  placeholder="请输入转出数量"
		/>
		<van-field
		  type="password"
		  label="交易密码"
		  :border="false"
		  placeholder="请输入交易密码"
		/>
		</van-dialog>
	</view>
</template>

<script>
export default {
	props: {
		dialogType: {
			type: [Number, String]
		},
		dialogShow: {
			type: Boolean
		}
	},
	data() {
		return {
			sum: '',
			text: ['转入', '转出']
		};
	},
	onReady() {
	},
	onLoad() {},
	methods: {
		onClose(event) {
			if (event.detail === 'confirm') {
			  // 异步关闭弹窗
			  setTimeout(() => {
				this.dialogShow = false
				uni.showToast({
					title: this.text[this.dialogType] + '成功',
					duration: 2000
				});
				this.$emit('emitClose', false)
			  }, 1000);
			} else {
			  this.dialogShow = false
			  this.$emit('emitClose', false)
			}
		 }
	}
};
</script>


<style scoped lang="scss">
	.dialog {
		&-title {
			padding: 20upx 0;
			font-size: 28upx;
			font-weight: 500;
			text-align: center;
		}
		&-sum {
			padding: 30upx;
			.sum {
				font-size: 28upx;
				color: #f4544d;
			}
		}
	}
</style>
